//
//  ConstructionDynamicTableViewCell.m
//  ShangHaiHuDongApp
//
//  Created by apple on 17/8/5.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "ConstructionDynamicTableViewCell.h"

@interface ConstructionDynamicTableViewCell ()
{
    UIImageView *logoImageView;
}
//标题
@property (nonatomic , strong) UILabel * cellTitleLabel;
//浏览数量
@property (nonatomic , strong) UILabel * scanNumberLabel;
//发布时间
@property (nonatomic , strong) UILabel * releaseTimeLabel;
//下方按钮
@property (nonatomic , strong) UIButton * optionButton;

@end

@implementation ConstructionDynamicTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initMyCell];
    }
    return self;
}


-(void)initMyCell{
    TenGrayShadowView *under = [[TenGrayShadowView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen zj_screenWith], 10 * [UIScreen zj_screenHScale])];
    under.backgroundColor = [UIColor themeGrayColor];
    under.isRemoveTop = YES;
    [self.contentView addSubview:under];
    //logo
    logoImageView = [[UIImageView alloc]initWithFrame:CGRectMake(ItemWidth * 24, ItemHeight * 45, ItemHeight * 39, ItemHeight * 39)];
    logoImageView.image = [UIImage imageNamed:@"mine_con_zzsh"];
    [self.contentView addSubview:logoImageView];
    
    [self.contentView addSubview:self.cellTitleLabel];
    
    //scanLogo
    UIImageView * scanImageView = [[UIImageView alloc]initWithFrame:CGRectMake(1,1,1,1)];
    scanImageView.image = [UIImage imageNamed:@"icon_conment"];
//    [self.contentView addSubview:scanImageView];
//    
//    [self.contentView addSubview:self.scanNumberLabel];
    [self.contentView addSubview:self.releaseTimeLabel];
    [self.contentView addSubview:self.optionButton];
    
//    scanImageView.sd_layout.leftSpaceToView(self.contentView , ItemWidth * 74).topSpaceToView(self.cellTitleLabel , ItemHeight * 19).widthIs(ItemWidth * 40).heightIs(ItemHeight * 32);
//    
//    self.scanNumberLabel.sd_layout.leftSpaceToView(scanImageView , ItemWidth * 12).topSpaceToView(self.cellTitleLabel , ItemHeight * 19).widthIs(ItemWidth * 200).heightIs(ItemHeight * 32);
    
    self.releaseTimeLabel.sd_layout.rightSpaceToView(self.contentView , ItemWidth * 23).topSpaceToView(self.cellTitleLabel , ItemHeight * 19).widthIs(ItemWidth * 200).heightIs(ItemHeight * 32);
    
    
    self.optionButton.sd_layout.leftSpaceToView(self.contentView , 0).bottomSpaceToView(self.contentView , -1).widthIs([UIScreen zj_screenWith]).heightIs(ItemHeight * 60);
}

-(void)setModel:(BranchNormalModel *)model
{
    _model = model;
    YBBranchNewsModel * tempModel = (YBBranchNewsModel *)model;
    self.cellTitleLabel.frame = CGRectMake(ItemWidth * 74, self.titleBeginY + 20 * ItemHeight, ItemWidth * 642, model.titleHeight);
    self.cellTitleLabel.attributedText = model.titleAttributedString;
//    self.scanNumberLabel.text = [NSString stringWithFormat:@"%@" , tempModel.NUM];
    if (tempModel.PUBLISHDATE.length >= 10) {
        NSString * tempString = [tempModel.PUBLISHDATE substringToIndex:10];
        tempString = [tempString stringByReplacingOccurrencesOfString:@"-" withString:@"."];
        self.releaseTimeLabel.text = tempString;
    }
    else{
        self.releaseTimeLabel.text = @"";
    }
    if ([model.typeString isEqualToString:@"5"]) {
        self.optionButton.hidden = YES;
        logoImageView.image = [UIImage imageNamed:@"kaoshi"];
    }else{
        self.optionButton.hidden = NO;
        logoImageView.image = [UIImage imageNamed:@"mine_con_zzsh"];
    }
}





//标题
-(UILabel *)cellTitleLabel
{
    if (!_cellTitleLabel) {
        _cellTitleLabel = [ToolClass creatLabelWithFrame:CGRectMake(ItemWidth * 74, ItemHeight * 25, ItemWidth * 642, ItemHeight * 39) font:16 textColor:[UIColor textBlackColor] text:@""];
    }
    return _cellTitleLabel;
}
//评论数量
-(UILabel *)scanNumberLabel
{
    if (!_scanNumberLabel) {
        _scanNumberLabel = [ToolClass creatLabelWithFrame:CGRectMake(ItemWidth * 74, ItemHeight * 90, ItemWidth * 500 , ItemHeight * 39) font:14 textColor:[UIColor textGrayColor] text:@""];
    }
    return _scanNumberLabel;
}

//下方按钮
-(UIButton *)optionButton
{
    if (!_optionButton) {
        _optionButton = [ToolClass createButtonWithFrame:CGRectMake(0, ItemHeight * 188, [UIScreen zj_screenWith], ItemHeight * 60) text:@"查看" textColor:[UIColor themeColor] imageName:@"" font:16];
        _optionButton.userInteractionEnabled = NO;
        _optionButton.backgroundColor = [UIColor zj_colorWithHexString:@"e8f2fa"];
//        _optionButton.layer.shadowOffset = CGSizeMake(0, 2);
//        _optionButton.layer.shadowColor = [UIColor blackColor].CGColor;
//        _optionButton.layer.shadowOpacity = 0.2;
    }
    return _optionButton;
}
//发布时间
-(UILabel *)releaseTimeLabel
{
    if (!_releaseTimeLabel) {
        _releaseTimeLabel = [ToolClass creatLabelWithFrame:CGRectMake(ItemWidth * 626, ItemHeight * 119, ItemWidth * 124, ItemHeight * 39) font:14 textColor:[UIColor textGrayColor] text:@""];
        _releaseTimeLabel.textAlignment = NSTextAlignmentRight;
    }
    return _releaseTimeLabel;
}


@end
